<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    //父类 
    function Person(name, age) {
      this.name = name;
      this.age = age;
    }
    Person.prototype.eat = function () {
      console.log("eat")
    }

    // 子类
    function Student(id, name, age){
        //构造函数继承
        Person.call(this,name,age)
        //给自己增加属性
        this.id = id
    }

    // 原型继承(指向父类的构造函数，不要直接赋值，否则修改子类也会修改掉父类。)
    Student.prototype = new Person

    //修正constructor 
    Student.prototype.constructor = Student;
    //给自己的原型增加方法
    Student.prototype.study = function () {
      console.log("node")
    }
    </script>
</body>
</html>